<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
	<title>移动端测试</title>
	<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
	<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
	<link rel="stylesheet" type="text/css" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css">
	<!-- 类库文件 -->
	<script src="dist/tp.js"></script>
</head>
<body>
<div class="container"><br><br>
	<h2>基本EOS操作</h2>
	<button class="btn btn-lg btn-warning" id="test">环境兼容测试</button>&nbsp;&nbsp;
	<button class="btn btn-lg btn-success" id="tran">转账测试</button>&nbsp;&nbsp;
	<button class="btn btn-lg btn-info" id="sel_balance">查询余额</button>&nbsp;&nbsp;
	<button class="btn btn-lg btn-warning" id="wallet_list">钱包列表</button>&nbsp;&nbsp;
	<button class="btn btn-lg btn-success" id="sel_eos_table">获取合约列表</button>&nbsp;&nbsp;
	<button class="btn btn-lg btn-info" id="get_history">获取历史记录</button>&nbsp;&nbsp;
	<button class="btn btn-lg btn-warning" id="get_auth">获取EOS签名</button>&nbsp;&nbsp;
	<hr>
	<h2>钱包操作</h2>
	<button class="btn btn-lg btn-info" id="sel_account_info">获取账户信息</button>&nbsp;&nbsp;
	<button class="btn btn-lg btn-warning" id="login">鉴权登录</button>&nbsp;&nbsp;
	<button class="btn btn-lg btn-success" id="app_info">获取APP信息</button>&nbsp;&nbsp;
	<button class="btn btn-lg btn-info" id="scan_qr">扫描引用二维码</button>&nbsp;&nbsp;
</div>

<script type="text/javascript">
//000.测试当前环境是否满足运行条件
$('#test').click(function(){
	//返回boolean类型
	alert(tp.isConnected());
});
$('#tran').click(function(){
	//001.EOS转账
	tp.eosTokenTransfer({
    	from: 'lvlvfenga521',	//转出账户
    	to: 'lvlvfenga522',		//转入账户
    	amount: '0.0100',		//金额
    	tokenName: 'EOS',		//币种
    	precision: 4,			//精度
    	contract: 'eosio.token',	//所调用的合约名
    	memo: '测试转账',		//备注
    	address: 'EOS5hkvkVRcsiKR9HKkVXTdnbT66NmNaDWPQccLFMxupHgq6QWxxb'	//转出的公钥账户
	}).then(function(result){
		alert(JSON.stringify(result));
	});
});
//002.查询EOS余额
$('#sel_balance').click(function(){
	tp.getEosBalance({
    	account: 'lvlvfenga521',	//查询的账户
    	contract: 'eosio.token',	//合约
    	symbol: 'EOS'				//币种
	}).then(function(result){
		alert(JSON.stringify(result));
	});
});
//003.获取eos钱包列表
$('#wallet_list').click(function(){
	tp.getWalletList('eos').then(function(result){
		alert(JSON.stringify(result));
	});
});
//004.获取合约列表
$('#sel_eos_table').click(function(){
	tp.getEosTableRows({
    	json: true,
    	code: 'test code',
    	scope: 'test scope',
    	table: 'table1',
    	lower_bound: '10',
    	limit: 20
	}).then(function(result){
		alert(JSON.stringify(result));
	});
});
//005.获取账户信息
$('#sel_account_info').click(function(){
	tp.getEosAccountInfo({
    	account: 'lvlvfenga522'
	}).then(function(result){
		alert(JSON.stringify(result));
	});
});
//006.获取历史信息
$('#get_history').click(function(){
	tp.getEosTransactionRecord({
    	start: 10,		//起始记录
		count: 20,		//总计条数
		account: 'lvlvfenga521',	//帐户名
		token: 'EOS',	//token种类
		sort: 'desc',	//排序规则
		contract: 'eosio.token'	//所属合约
	}).then(function(result){
		alert(JSON.stringify(result));
	});
});
//007.获取EOS签名
$('#get_auth').click(function(){
	tp.eosAuthSign({
		from: 'lvlvfenga521',	
		publicKey: 'EOS5hkvkVRcsiKR9HKkVXTdnbT66NmNaDWPQccLFMxupHgq6QWxxb',
		signdata: '签名信息：something to sign'
	}).then(function(result){
		alert(JSON.stringify(result));
	});
});




//EOS账户权限机制详解：https://blog.csdn.net/HiBlock/article/details/80531477
//方法调用列表 参考自开源项目：https://github.com/TP-Lab/tp-eosjs
//- [1.EOS](#1eos)EOS合约指令
    // - [1.1 tp.eosTokenTransfer](#11-转账)
    // - [1.2 tp.pushEosAction](#12-添加到Action)
    // - [1.3 tp.getEosBalance](#13-获取合约)
    // - [1.4 tp.getTableRows (Deprecated)](#14-获取表信息)已弃用！
    // - [1.5 tp.getEosTableRows](#15-获取EOS表信息)
    // - [1.6 tp.getEosAccountInfo](#16-获取账户信息)
    // - [1.7 tp.getEosTransactionRecord](#17-获取交易记录)
    // - [1.8 tp.eosAuthSign](#18-EOS签名)
// - [2. COMMON](#2-common)TP指令
    // - [2.1 tp.getAppInfo](#21-获取app信息)
    // - [2.2 tp.getWalletList](#22-获取钱包列表)
    // - [2.3 tp.getDeviceId](#23-获取设备标识)
    // - [2.4 tp.shareNewsToSNS](#24-分享到sns)
    // - [2.5 tp.invokeQRScanner](#25-调用二维码扫描)
    // - [2.6 tp.getCurrentWallet](#26-tp获取当前钱包)
    // - [2.7 tp.getWallets](#27-获得钱包)
    // - [2.8 tp.sign](#28-签名)
    // - [3.9 tp.back](#39-回退)
    // - [3.10 tp.close](#310-关闭)
    // - [3.11 tp.fullScreen](#311-全屏)
</script>

</body>
</html>